<?php
/***************************************************************
* SMFModCreator-Main.template.php                              *
*--------------------------------------------------------------*
* SMF Mod Creator                                              *
* Version 0.1 Alpha                                            *
* Written By: Labradoodle-360                                  *
*--------------------------------------------------------------*
* Copyright 2011 Matthew Kerle - All Rights Reserved           *
*--------------------------------------------------------------*
* Redistribution and use in source and binary forms, with or   *
* without modification, are permitted provided that the        *
* conditions specified in the attached                         *
* smfmodcreator_license.txt file are met.                      *
***************************************************************/

function template_creator_view()
{

	// Globalize everything we'll need...
	global $context, $settings, $txt, $scripturl, $page_links, $notifications;

	retrieveSMFFiles();

	// Notifications? The good kind.
	if (!empty($notifications))
	{
		echo '<div class="rounded" id="profile_success">
				<span class="floatleft" style="width: 18px; margin-right: 2px;">
					<img src="', $settings['default_images_url'], '/smfmodcreator/tick.png" alt="" border="0" style="vertical-align: middle;" />
				</span>
				', $notifications[$_REQUEST['notify']], '
		</div>';
	}

	echo '<div class="cat_bar">
			<h3 class="catbg">' . $txt['smfmc_allmods'] . '</h3>
		</div>', template_show_list('modifications');

}

function template_project_view()
{

	// Globalize everything we'll need...
	global $modification, $context, $txt, $settings, $scripturl, $directories;

	// Name + Summary
	echo '<div class="cat_bar">
		<h3 class="catbg">', $modification['name'], '</h3>
	</div>
	<div class="information">', $modification['summary'], '</div>';

	// Our basic layout is two columns, for the most part?
	echo '<div class="floatleft" style="width: 24%;">
			<div class="cat_bar" style="height: 28px;">
				<h3 class="catbg">
					<span class="floatleft" style="width: 18px; margin-right: 2px">
						<img src="', $settings['default_images_url'], '/smfmodcreator/information.png" alt="" style="margin-top: 7px;" />
					</span>', $txt['smfmc_info'],  '
				</h3>
			</div>
			<div class="roundframe rfix">
				<div class="innerframe">
					<div class="content smalltext">
						<strong>', $txt['smfmc_submitted'], '</strong><br />&nbsp;&nbsp;&nbsp;', $modification['submitted'], '
						<hr />
						<strong>', $txt['smfmc_cat'], ':</strong><br />&nbsp;&nbsp;&nbsp;', $modification['category']['name'], '
						<hr />
						<strong>', $txt['smfmc_last_modified'], ':</strong><br />&nbsp;&nbsp;&nbsp;', $modification['modified_time'], '
					</div>
				</div>
			</div>
			<span class="lowerframe"><span></span></span>
			<div class="cat_bar upper_space" style="height: 28px;">
				<h3 class="catbg">
					<span class="floatleft" style="width: 18px; margin-right: 2px;">
						<img src="', $settings['default_images_url'], '/smfmodcreator/user-worker-boss.png" alt="" style="margin-top: 6px;" />
					</span>', $txt['smfmc_dev_by'], '
					<span class="floatright" style="width: 18px; margin-right: -4px;">
						<img src="', $settings['default_images_url'], '/smfmodcreator/', !empty($modification['author']['online']) ? 'status_online' : 'user_silhouette', '.png" alt="" style="margin-top: 6px;" title="', $txt['smfmc_dev_is'], !empty($modification['author']['online']) ? $txt['online'] : $txt['offline'], '"/>
					</span>
				</h3>
			</div>
			<div class="roundframe rfix">
				<div class="innerframe">
					<div class="content" style="text-align: center;">
						', !empty($modification['author']['avatar']) ? '<span style="border: 1px solid #ccc; padding: 6px; display: block;">' . $modification['author']['avatar'] . '</span>' : '', '
						<br />
						<span style="font-size: medium; font-family: sans serif;">
							', $modification['author']['link'], '
						</span>
						<span style="border-top: 1px dashed #ccc; display: block; margin-top: 4px; padding-top: 4px;">
							<span style="color: #ccc;">~', $modification['author']['group'], '~</span>
						</span>
					</div>
				</div>
			</div>
		<span class="lowerframe"><span></span></span>
		</div>
		<div class="floatright" style="width: 75%;">
			<div class="cat_bar" style="height: 28px;">
				<h3 class="catbg">
					<span class="floatleft" style="width: 18px; margin-right: 2px;">
						<img src="', $settings['default_images_url'], '/smfmodcreator/blue-document-list.png" alt="" style="margin-top: 6px" />
					</span>Files Modified
				</h3>
			</div>
			<div class="roundframe rfix">
				<div class="innerframe">
					<div class="content">';
						echo '<pre>', print_r($modification['modified_files']), '</pre>';
						if (!isset($modification['files']))
						{
							echo '<div class="smalltext">Sorry, it appears there are currently no files modified by ', $modification['name'], '.</div><div class="smalltext" style="margin-top: 5px; border-top: 1px dashed #ccc; padding-top: 5px;"><a href="#">Add Modifications</a></div>';
						}
						else
						{
							$last = end($modification['files']);
							foreach ($modification['files'] as $idFile => $file)
							{
								echo '<div class="', $last['file_name'] == $file['file_name'] ? 'last_' : '', 'files">-> <a href="#">', $file['file_name'] .  $file['file_type'], '</a></div>';
							}
							echo '<div class="smalltext" style="margin-left: 4px;"><strong>', $txt['smfmc_currdir'], ':</strong> /smfmodcreator/modifications/', $modification['identifier'], '/</div>';
						}
				echo '</div>
				</div>
			</div>
			<span class="lowerframe"><span></span></span>
		</div>
	<br class="clear" />';

}

function template_creator_create()
{

	// Globalize everything we'll need here...
	global $settings, $scripturl, $context, $txt, $categories, $user_info, $errors;

	// We all love error notices, don't we?
	if (!empty($errors))
	{
		echo '<div id="profile_error">', $_POST['id_category'] != 'easter' ? 'We encountered the following errors:<ul>' : base64_decode('U2VyaW91c2x5PyBPbmx5IG4wMGJzIG1ha2UgbWlzdGFrZXMgbGlrZSB0aGVzZTo=') . '<ul><li>You must select a category for your modification.</li>';
		foreach ($errors as $var => $val)
		{
			echo '<li>', $val, '</li>';
		}
		echo '</ul></div>';
	}

	// Shouldn't need to be any introductions ;)
	echo '<div class="cat_bar upper_space" style="height: 28px;">
			<h3 class="catbg">Package Information</h3>
		</div>
		<div class="roundframe rfix">
			<div class="innerframe">
				<div class="content">
					<form action="', $scripturl, '?action=modcreator;page=create_mod" method="post">
						<div class="floatleft" style="width: 24%; margin-top: 6px; margin-left: 4px;">
							<label for="mod_name">
								<span style="font-weight: bold;">Modification Name:</span>
							</label>
						</div>
						<div class="floatright" style="width: 75%;">
							<input type="text" id="mod_name" name="mod_name" class="rounded cust_input" maxlength="255" style="width: 40%;"', !empty($_POST['mod_name']) ? ' value="' . $_POST['mod_name'] . '"' : '', ' />
						</div>
						<br class="clear" />
						<hr />
						<div class="floatleft" style="width: 24%; margin-top: 6px; margin-left: 4px;">
							<label for="id_category">
								<span style="font-weight: bold;">Category:</span>
							</label>
						</div>
						<div class="floatright" style="width: 75%;">
							<select id="id_category" name="id_category" class="rounded cust_input" style="width: 41%;">
								<option value=""', !isset($_POST['id_category']) ? 'selected="selected"' : '', '>Select a Category:</option>
								<optgroup label="Categories">';
								foreach ($categories as $cat_id => $category)
								echo '<option value="' , $cat_id, '"', isset($_POST['id_category']) && $_POST['id_category'] == $cat_id ? ' selected="selected"' : '', '>' , $category, '</option>';
								echo !empty($errors) ? '<option value="easter">Easter</option>' : '';
							echo '</optgroup>
							</select>
						</div>
						<br class="clear" />
						<hr />
						<div class="floatleft" style="width: 24%; margin-top: 6px; margin-left: 4px;">
							<label for="summary">
								<span style="font-weight: bold;">Summary:</span>
							</label>
						</div>
						<div class="floatright" style="width: 75%;">
							<input type="text" id="summary" name="summary" class="rounded cust_input" maxlength="255" style="width: 40%;"', !empty($_POST['summary']) ? ' value="' . $_POST['summary'] . '"' : '', ' />
						</div>
						<br class="clear" />
						<hr />
						<input type="hidden" id="author_id" name="author_id" value="', $user_info['id'], '" />
						<input type="hidden" id="submitted" name="submitted" value="', time(), '" />
						<input type="hidden" id="author_name" name="author_name" value="', $user_info['name'], '" />
						<input type="submit" value="Create" class="rounded cust_button" />
					</form>
				</div>
			</div>
		</div>
	<span class="lowerframe"><span></span></span>';

}

function template_copyright_above()
{

	// Globalize everything we'll need...
	global $page_links, $settings;

	// What would you like to do?
	$first_link = reset($page_links);
	echo '<div class="spacer">';
		foreach ($page_links as $var => $val)
		{
			echo '<div class="floatleft smalltext" style="width: 12%; margin-right: 1%;', $first_link['title'] == $val['title'] ? ' margin-left: 36%;' : '', '">
					<a href="', $val['href'], '" class="', isset($_REQUEST['page']) && $_REQUEST['page'] == $var ? 'active_' : '', 'selector rounded" style="height: 55px; text-align: center;">
					<img src="', $settings['default_images_url'], '/smfmodcreator/', $val['icon'], '" alt="" style="margin-top: 5px; width: 28px; height: 28px;" />
					<br />
					<span class="tlink">', $val['title'], '</span>
				</a>
			</div>';
		}
		echo '<br class="clear" />
	</div>';

}

function template_copyright_below()
{

echo '<div class="smalltext centertext"><a href="http://code.google.com/p/smf-mod-creator/" target="_blank">SMF Mod Creator</a> - <a href="http://www.simplemachines.org/community/index.php?action=profile;u=182638" target="_blank">&copy; 2011 Matthew Kerle</a></div>';

}

?>